package com.powernode.spring6;

import com.powernode.spring6.bean.FactoryBean.Order;
import com.powernode.spring6.bean.FactoryBean.interfaceInit.Person;
import com.powernode.spring6.bean.constructor.User;
import com.powernode.spring6.bean.simpleFactory.Vip;
import com.powernode.spring6.bean.userDefinedDateInit.Student;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class testBean {


    @Test
    public void testUser(){
        // 无参构造方法执行测试
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        User userBean = applicationContext.getBean("userBean", User.class);

    }

    @Test
    public void testVipFactory() {

        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        Vip vip = applicationContext.getBean("vipBean", Vip.class);
        System.out.println(vip);
    }

    @Test
    public void testOrderFactory() {

        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        Order order = applicationContext.getBean("orderBean", Order.class);
        System.out.println(order);
    }

    @Test
    public void testPersonFactoryInterface() {

        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        Person person = applicationContext.getBean("personFactoryBean", Person.class);
        System.out.println(person);
    }

    @Test
    public void testUserDefinedDateInit() {

        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        Student student = applicationContext.getBean("studentBean", Student.class);
        System.out.println(student);
    }

    @Test
    public void DateFactory() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        Student student = applicationContext.getBean("studentBeanDateFormatter", Student.class);
        System.out.println(student);
    }


}
